package viettravel.guiandevent.map;

import java.util.ArrayList;

import viettravel.DAO.MoveMapDAO;
import viettravel.common.Constants;
import viettravel.guiandevent.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ListLocalMapAdapter extends BaseAdapter {

	private ArrayList<MoveMapDAO> mListMoveMap;
	private Context mContext;
	
	public ListLocalMapAdapter(Context _context, ArrayList<MoveMapDAO> _rowPlace){
		mListMoveMap = new ArrayList<MoveMapDAO>();
		mListMoveMap.addAll(_rowPlace);
		mContext = _context;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mListMoveMap.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mListMoveMap.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View _view, ViewGroup _viewGroup) {
		// TODO Auto-generated method stub
		View view = _view;
		if (view == null){
			LayoutInflater layoutInflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = layoutInflater.inflate(R.layout.row_move_map, null);
        }
		
		MoveMapDAO l = mListMoveMap.get(position);
		ImageView rowLocalImage = (ImageView)view.findViewById(R.id.rowMoveImage);
		TextView rowMoveDistance = (TextView)view.findViewById(R.id.rowMoveDistance);
		TextView rowMoveDescription = (TextView)view.findViewById(R.id.rowMoveDescription);
		
		rowLocalImage.setBackgroundDrawable(l.getDrawable());
		
		rowMoveDescription.setTypeface(Constants.TYPEFACE_NYALA);
		rowMoveDescription.setText(l.getDescription());
		
		rowMoveDistance.setTypeface(Constants.TYPEFACE_NYALA);
		rowMoveDistance.setText(l.getDistance());                      
		return view;
	}
}
